package cl.dkns.yapal.core;

import cl.dkns.yapal.core.db.DatabaseAccess;
import cl.dkns.yapal.core.db.DatabaseAccessImpl;
import cl.dkns.yapal.core.db.DatabaseException;
import cl.dkns.yapal.core.db.mapping.Category;
import cl.dkns.yapal.core.db.mapping.Product;
import cl.dkns.yapal.core.db.mapping.User;


public class ServiceImpl implements Service {

    private DatabaseAccess databaseAccess;

    /**
     *
     * @param product
     * @throws ServiceException
     */
    public void addProduct(Product product) throws ServiceException {

        try {

            databaseAccess.addProduct(product);

        } catch (DatabaseException e) {
            throw new ServiceException(e);
        }
    }

    /**
     *
     * @param user
     * @throws ServiceException
     */
    public void addUser(User user) throws ServiceException {

        try {

            databaseAccess.addUser(user);

        } catch (DatabaseException e) {
            throw new ServiceException(e);
        }
    }

    /**
     *
     * @param category
     * @throws ServiceException
     */
    public void addCategory(Category category) throws ServiceException {

        try {

            databaseAccess.addCategory(category);

        } catch (DatabaseException e) {
            throw new ServiceException(e);
        }
    }


    public void setDatabaseAccess(DatabaseAccessImpl databaseAccess) {
        this.databaseAccess = databaseAccess;
    }


}
